<{include file=$module.'/header.php'}>
<div class="page goods-add" id="page-goods-post">
	<header class="bar bar-nav common-bar-nav">
		<a class="pull-left back"><i class="fa fa-arrow-left"></i></a>
		<h1 class="title"><{$act_name}></h1>
	</header>
	<{include file=$module.'/nav.php'}>
	<div class="btn-submit">
		<a href="javascript:;" class="button button-big button-fill button-danger submit-com">提交</a>
	</div>
	<div class="content">
		<form id="form" >
		<input type="hidden" name="id" value="<{$info.id}>" />
		<input type="hidden" name="do" value="<{$action}>" />
		<input type="hidden" name="data[order_status]" value="<{$order_status}>" />
		<{if $info.photos}>
		<div class="content-block-title">图片</div>
		<div class="image-container muti-upload">
			<ul class="upload-list p-b-0">
				<{foreach $info.photos as $val}>
				<li><img src="<{$val}>"></li>
				<{/foreach}>
			</ul>
		</div>
		<{/if}>
		<div id="order-detail">
			<!-- <div class="content-block-title">订单</div>
			<div class="list-block">
				<ul>
					<li class="item-content">
						<div class="item-inner">
							<div class="item-title">编号</div>
							<div class="item-after"><{$info.id}></div>
						</div>
					</li>
					<li class="item-content">
						<div class="item-inner">
							<div class="item-title">状态</div>
							<div class="item-after"><span class="color-danger"><{$orderStatus[$info.order_status]}></span></div>
						</div>
					</li>
				</ul>
			</div> -->
			<!-- <div class="content-block-title">详情</div>
			<div class="list-block">
				<ul>
					<li>
						<div class="item-content">
							<div class="item-inner">
								<div class="item-title label">区域</div>
								<div class="item-after"><{$info.parea.name}> - <{$info.area.name}></div>
							</div>
						</div>
					</li>
					<li>
						<div class="item-content">
							<div class="item-inner">
								<div class="item-title label">分类</div>
								<div class="item-after"><{$info.pcate.name}> - <{$info.cate.name}></div>
							</div>
						</div>
					</li>
					<li>
						<div class="item-content">
							<div class="item-inner">
								<div class="item-title label">地点</div>
								<div class="item-after"><{$info.pzone.name}> - <{$info.zone.name}></div>
							</div>
						</div>
					</li>
				</ul>
			</div>
			<div class="list-block">
				<ul>
					<li>
						<div class="item-content">
							<div class="item-inner">
								<div class="item-title label">标题</div>
								<div class="item-after"><{$info.title}></div>
							</div>
						</div>
					</li>
					
					<li>
						<div class="item-content">
							<div class="item-inner">
								<div class="item-title label">位置</div>
								<div class="item-after"><{$info.local}></div>
							</div>
						</div>
					</li>
				</ul>
			</div> -->
			
			<!-- <div class="content-block-title">人员</div>
			<div class="list-block m-b-0  other-info">
				<ul>
					<li class="item-content">
						<div class="item-inner">
							<div class="item-title">报修员</div>
							<div class="item-after"><{$info.admin.realname}> <a class="item-after external" href="tel:<{$info.admin.tel}>"><span class="color-danger"><{$info.admin.tel}></span></a></div>
						</div>
					</li>
					<li class="item-content">
						<div class="item-inner">
							<div class="item-title">师傅</div>
							<div class="item-after"><{$info.shifu.realname}> <a class="item-after external" href="tel:<{$info.shifu.tel}>"><span class="color-danger"><{$info.shifu.tel}></span></a></div>
						</div>
					</li>
				</ul>
			</div> -->
			
			<{if $order_status==5}>
			<div class="list-block">
				<ul>
					<li class="align-top">
						<div class="item-content">
							<div class="item-inner">
								<div class="item-input">
									<textarea name="data[cl_info]" placeholder="请输入材料明细"></textarea>
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="item-content">
							<div class="item-inner">
								<div class="item-title label">材料费用</div>
								<div class="item-input">
									<input type="text" name="data[cl_money1]" value="" placeholder="请输入材料费用">
								</div>
							</div>
						</div>
					</li>
					<li>
						<div class="item-content">
							<div class="item-inner">
								<div class="item-title label">人工费用</div>
								<div class="item-input">
									<input type="text" name="data[cl_money2]" value="" placeholder="请输入人工费用">
								</div>
							</div>
						</div>
					</li>
					<!-- <li>
						<div class="item-content">
							<div class="item-inner">
								<div class="item-title label">费用合计</div>
								<div class="item-input">
									<input type="text" id="data-realname" name="rg_money" value="" placeholder="请输入总费用">
								</div>
							</div>
						</div>
					</li> -->
				</ul>
			</div>
			<{/if}>

			<div class="content-block-title">备注</div>
			<div class="list-block m-b-0 other-info">
				<ul>
					<li class="align-top">
						<div class="item-content">
							<div class="item-inner">
								<div class="item-input">
									<textarea name="data[intro]" placeholder="请输入操作备注"></textarea>
								</div>
							</div>
						</div>
					</li>
				</ul>
			</div>

			<div class="content-block-title">图片</div>
			<div class="image-container muti-upload">
				<ul id="upload-list" class="upload-list p-b-1">
					<li class="list-button"><input id="upload-select" type="file" capture="camera" /><i class="fa fa-plus"></i></li>
				</ul>
			</div>

		</div>
		</form>
		<div class="ui-footspace"></div>
	</div>
</div>


<script src="/static/app/js/qcing.js"></script>
<script src="/static/app/js/upload.js"></script>
<script>
$(function(){

	$(document).on('click', '.submit-com', function(){
		var $this = $(this);
		var order_id = $this.data('id');
		if($this.hasClass('disabled')) {
			return false;
		}
		
		var params = $('#form').serializeArray();
		$this.addClass('disabled');
		$.post("/<{$routeUrl}>/<{$action}>", params, function(response){
			if(response.code == 0){
				$this.removeClass('disabled');
				$.toast(response.msg);
				return false;
			}
			if(response.code == 1){
				$.toast(response.msg, response.url);
			}
		});
	})


	<{if $info.photos}>
	/*=== 默认为 standalone ===*/
	var myPhotoBrowserStandalone = $.photoBrowser({
	    photos : [
	  		<{foreach $info.photos as $val}>
	  		'<{$val}>',
			<{/foreach}>
			
			<{if $info.logs}>
	  		<{foreach $info.logs as $key => $val}>
				<{if $val.intro.photos}>
					<{foreach $val.intro.photos as $v}>
					'<{$v}>',
					<{/foreach}>
				<{/if}>
			<{/foreach}>
			<{/if}>
	    ]
	});
	<{/if}>

	//图片预览
	$(document).on('click','.image-container img', function(e){ 
		myPhotoBrowserStandalone.open();
	});

	//上传图片
	$(document).on('change', '#upload-select', function(e){ 
		for(var i=0;i<this.files.length;i++){
			// console.log(this.files[i]);

			lhj(this.files[i], {
			    width:1000,
			    height:1000,
			    // 压缩成功
			    done: function (results) {
					postdata = {
						base64: results.base64,
						name: results.origin.name,
						type: results.origin.type,
						size: results.origin.size,
					};
					$.post('/<{$module}>/api/upload', postdata, function(response){
						if(response.code == 0){
							error("上传失败");
							return false;
						}
						if(response.code == 1){
							txt = "<li><img src='" + results.base64+"'><a href='javascript:;' class='remove'>删除</a><input type='hidden' name='photo[]' value='"+ response.data +"'></li>";
			    			$("#upload-list").append(txt);
						}
					});
			    }
			});
		}
	});
	//删除图片
	$(document).on('click', '.remove', function(e){ 
	 	var file_id = $(this).parent().find("input").val();
		$.post('/<{$module}>/api/remove', { file_id: file_id }, function(data){ 
		});
	 	$(this).parent().remove();
	});


	
});

</script>
<{include file=$module.'/footer.php'}>